package com.example.proxy.cglib;

import org.springframework.cglib.core.DebuggingClassWriter;

/**
 * <p> CGLib 代理 </p>
 *
 * @author Chris
 * @since 2022/11/29 14:01
 */
public class CglibProxyTest {

    public static void main(String[] args) {
        // 生成代理类文件
        System.setProperty(DebuggingClassWriter.DEBUG_LOCATION_PROPERTY, "D:\\Workspace\\99_Others\\Java\\demo-spring-framework");

        UserServiceImpl personBean = new UserServiceImpl();
        personBean.setName("Chris");

        CglibProxy cglibProxy = new CglibProxy();
        UserServiceImpl proxy = cglibProxy.newInstance(personBean);
        proxy.sayHello();
        proxy.haha();

        System.out.println("--------------");

        final UserService userService = cglibProxy.newInstance(UserService.class);
        userService.sayHello();

    }

}